#ifndef __SYSTEM_H
#define __SYSTEM_H

#include "stdint.h"

#define SYSTEM_PRIORITYGROUP_0         0x00000700U /*!< 0 bits for pre-emption priority 4 bits for subpriority */
#define SYSTEM_PRIORITYGROUP_1         0x00000600U /*!< 1 bits for pre-emption priority 3 bits for subpriority */
#define SYSTEM_PRIORITYGROUP_2         0x00000500U /*!< 2 bits for pre-emption priority 2 bits for subpriority */
#define SYSTEM_PRIORITYGROUP_3         0x00000400U /*!< 3 bits for pre-emption priority 1 bits for subpriority */
#define SYSTEM_PRIORITYGROUP_4         0x00000300U /*!< 4 bits for pre-emption priority 0 bits for subpriority */

typedef enum {
	SYSTEM_CLK_SYS,
	SYSTEM_CLK_AHB,
	SYSTEM_CLK_APB1,
	SYSTEM_CLK_APB2,
	SYSTEM_CLK_ADC,
	SYSTEM_CLK_USART0
} SYSTEM_CLK_E;

typedef enum {
	SYSTEM_CLK_UNIT_HZ,
	SYSTEM_CLK_UNIT_KHZ,
	SYSTEM_CLK_UNIT_MHZ
} SYSTEM_CLK_FREQ_UNIT_E;

typedef enum {
	SYSTEM_CLK_SOURCE_IRC8M,
	SYSTEM_CLK_SOURCE_HXTAL,
	SYSTEM_CLK_SOURCE_PLL,
	SYSTEM_CLK_SOURCE_NULL
} SYSTEM_CLK_SORCE_E;

void SystemSetInterruptGroup(uint32_t PriorityGroup);
uint32_t SystemGetClkFreq(SYSTEM_CLK_E clock, SYSTEM_CLK_FREQ_UNIT_E unit);
SYSTEM_CLK_SORCE_E SystemGetClkSource(void);

#endif
